<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="/static/assets/img/login1.png">
    <link rel="apple-touch-icon-precomposed" href="/static/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="/static/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="/static/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="/static/assets/css/app.css">
    <script src="/static/assets/js/jquery.min.js"></script>
    <style>
        .am-dropdown-toggle{
            color: rgb(182, 182, 183);
            font-size: 0.8rem;
        }
        .am-dropdown-content{
            font-size: 0.8rem;
        }
        .contentst{
            width: 50rem;
            height: 2rem;
            display: inline-block;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }
        .pagination{
            margin: 0 auto;
            width: 600px;
            text-align: center;
        }
        .pagination>li{
            margin-right: 1rem;
            width: 3rem;
            height: 3rem;
            line-height: 3rem;
            background-color: rgba(127, 146, 145, 0.315);
            float: left;
        }
        .active{
            font-size: 2rem;
            background-color: aqua;
            color: rgb(87, 85, 85);
        }
    </style>
</head>

<body data-type="chart">
    <script src="/static/assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 头部 -->
        <header>
            <!-- logo -->
            <div class="am-fl tpl-header-logo">
                <a href="javascript:;"><img src="/static/assets/img/log.png" alt="" style="height: 50px;width: 140px;"></a>
            </div>
            <!-- 右侧内容 -->
            <div class="tpl-header-fluid">
                <!-- 侧边切换 -->
                <div class="am-fl tpl-header-switch-button am-icon-list">
                    <span>

                </span>
                </div>
                <!-- 搜索 -->
                <div class="am-fl tpl-header-search">
                    <form class="tpl-header-search-form" action="javascript:;">
                        <button class="tpl-header-search-btn am-icon-search"></button>
                        <input class="tpl-header-search-box" type="text" placeholder="搜索内容...">
                    </form>
                </div>
                <!-- 其它功能-->
                <div class="am-fr tpl-header-navbar">
                    <ul>
                        <!-- 欢迎语 -->
                        <li class="am-text-sm tpl-header-navbar-welcome">
                            <a href="javascript:;">欢迎您回来,亲爱的 <span>{$Think.session.name.admName}</span> </a>
                        </li>

                        <!-- 新邮件 -->
                        <li class="am-dropdown tpl-dropdown" data-am-dropdown>
                            <a href="http://127.0.0.1:5500/index.html" target="_blank">
                                <i class="am-icon-book"></i>文章系统前台
                                <!-- <span class="am-badge am-badge-success am-radius item-feed-badge">文章</span> -->
                            </a>
                        </li>

                        <!-- 退出 -->
                        <li class="am-text-sm">
                            <a href="javascript:;">
                                <span class="am-icon-sign-out"></span> 退出
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

        </header>
        <!-- 风格切换 -->
        <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                </div>
            </div>
        </div>
        <!-- 侧边导航栏 -->
        <div class="left-sidebar">
            <!-- 用户信息 -->
            <div class="tpl-sidebar-user-panel">
                <div class="tpl-user-panel-slide-toggleable" style="text-align: center;">
                    <div class="tpl-user-panel-profile-picture" style="margin: 0 auto">
                        <img id="image" src="/static/uploads/{$Think.session.name.admAvatar}" alt="">
                    </div>
                    <span class="user-panel-logged-in-text">
                        <i class="am-icon-circle-o am-text-success tpl-user-panel-status-icon"></i>
                        {$Think.session.name.admName}
                    </span>
                    <a href="javascript:;" class="tpl-user-panel-action-link">
                        <span class="am-icon-black-tie"></span>
                        <li class="am-dropdown" data-am-dropdown>
                            <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                                {$Think.session.name.admAuthor} <span class="am-icon-caret-down"></span>
                            </a>
                            <ul class="am-dropdown-content">
                              <li class="am-dropdown-header">操作</li>
                              <li><a id="doc-prompt-toggle"><span class="am-icon-key"></span> 修改密码</a></li>
                              <li><a href="javascript:;" id="upload"><span class="am-icon-slideshare"></span> 更换头像</a></li>
                              <li class="am-divider"></li>
                              <li><a href="http://cms.com:8081/admin/admin/admOut?id={$Think.session.name.admID}"><span class="am-icon-sign-out"></span> 退出登录 </a></li>
                            </ul>
                        </li>
                    </a>
                </div>
            </div>

            <div style="display: none;">
                    <input id="file" type="file" name="image" onchange="uploadFile()">
            </div>
            <script>
                $("#upload").click(function(){
                    $("#file").click()
                })
                function uploadFile() {
                    var myform = new FormData();
                    // var id = {$Think.session.name.admID};
                    myform.append('image',$('#file')[0].files[0]);
                    $.ajax({
                        url: "http://cms.com:8081/admin/admin/admPhotoUp?id="+"{$Think.session.name.admID}",
                        type: "POST",
                        data: myform,
                        contentType: false,
                        processData: false,
                        success: function (data) {
                            $("#image").attr("src",'/static/uploads/'+JSON.parse(data))
                            console.log($("#image"))
                            $("#alert").css('display','block')
                            setTimeout(()=>{$("#alert").css('display','none')},4000)
                            console.log(data);
                        },
                        error:function(data){
                            console.log(data)
                        }
                    });
                }
            </script>
            <div class="am-alert am-alert-success" data-am-alert style="display: none; " id="alert">
                <button type="button" class="am-close">&times;</button>
                <p>没什么可给你，但求凭这阙歌。谢谢你风雨里，都不退愿陪着我。更改成功！</p>
            </div>
    
            <!-- 菜单 -->
            <ul class="sidebar-nav">
                <li class="sidebar-nav-heading">CMS<span class="sidebar-nav-heading-info"> 内容管理系统</span></li>
                <li class="sidebar-nav-link">
                    <a href="http://cms.com:8081/admin/admin/showHome">
                        <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
                    </a>
                </li>
                {if $Think.session.name.admAuthor != '超级管理员'}
                    <li class="sidebar-nav-link" style="pointer-events: none;">
                        <a href="#">
                            <i class="am-icon-user-secret sidebar-nav-link-logo"></i>
                             管理员列表
                            <i class="am-icon-warning sidebar-nav-link-logo" style="color: red;"></i>
                        </a>
                    </li>
                {else}
                    <li class="sidebar-nav-link">
                        <a href="http://cms.com:8081/admin/admin/showCalendar">
                            <i class="am-icon-user-secret sidebar-nav-link-logo"></i> 管理员列表
                        </a>
                    </li>
                {/if}
                <li class="sidebar-nav-link">
                    <a href="http://cms.com:8081/admin/admin/showTables">
                        <i class="am-icon-user sidebar-nav-link-logo"></i> 用户列表
                    </a>
                </li>

                <!-- 文章管理 -->
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title">
                        <i class="am-icon-book sidebar-nav-link-logo"></i> 文章管理
                        <span class="am-icon-chevron-up am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub">
                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showTableList">
                                <span class="am-icon-gg sidebar-nav-link-logo"></span> 分类管理
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showTableListImg">
                                <span class="am-icon-gg sidebar-nav-link-logo"></span> 文章列表
                            </a>
                        </li>
                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showArtDown">
                                <i class="am-icon-gg sidebar-nav-link-logo"></i> 待审文章
                                <span class="am-badge am-badge-secondary sidebar-nav-link-logo-ico am-round am-fr am-margin-right-sm"></span></span>
                            </a>
                        </li>
                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showFour">
                                <i class="am-icon-gg sidebar-nav-link-logo"></i> 上传文章
                            </a>
                        </li> 
                    </ul>
                </li>

                <!-- 评论管理 -->
                <li class="sidebar-nav-link">
                    <a href="javascript:;" class="sidebar-nav-sub-title">
                        <i class="am-icon-commenting sidebar-nav-link-logo"></i> 评论管理
                        <span class="am-icon-chevron-down am-fr am-margin-right-sm sidebar-nav-sub-ico"></span>
                    </a>
                    <ul class="sidebar-nav sidebar-nav-sub"  style="display: block;">
                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showForm">
                                <span class="am-icon-gg sidebar-nav-link-logo"></span> 音频列表
                            </a>
                        </li>

                        <li class="sidebar-nav-link">
                            <a href="http://cms.com:8081/admin/admin/showChart" class="active">
                                <span class="am-icon-gg sidebar-nav-link-logo"></span> 评论列表
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="sidebar-nav-link">
                    <a href="http://cms.com:8081/admin/admin/showSignUp">
                        <i class="am-icon-keyboard-o sidebar-nav-link-logo"></i> 注册
                        <!-- <span class="am-badge am-badge-secondary sidebar-nav-link-logo-ico am-round am-fr am-margin-right-sm">6</span> -->
                    </a>
                </li>
                <li class="sidebar-nav-link">
                    <a href="http://cms.com:8081/admin/admin/showLogin">
                        <i class="am-icon-key sidebar-nav-link-logo"></i> 登录
                    </a>
                </li>

            </ul>
        </div>

        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            

            <div class="row-content am-cf">
                <table width="100%" class="am-table am-table-compact am-table-bordered am-table-radius am-table-striped tpl-table-black " id="example-r">
                    <thead>
                        <tr>
                            <th class="am-text-center am-text-middle">序号</th>
                            <th class="am-text-center am-text-middle">评论内容</th>
                            <th class="am-text-center am-text-middle">评论用户</th>
                            <th class="am-text-center am-text-middle">评论时间</th>
                            <th class="am-text-center am-text-middle">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach $data as $k=>$v}
                        <tr class="gradeX">
                            <td class="am-text-center am-text-middle">{$k+1}</td>
                            <td class="am-text-middle" style="width: 51rem;">
                                <div class="contentst">
                                {$v.comContent}
                                </div>
                            </td>
                            <td class="am-text-center am-text-middle">{$v.user.0.userName}</td>
                            <td class="am-text-center am-text-middle">{$v.dateline}</td>
                            <td class="am-text-center am-text-middle">
                                <div class="tpl-table-black-operation">
                                    <a onclick="commentDel('{$v.comtID}')" class="tpl-table-black-operation-del">
                                        <i class="am-icon-trash"></i> 删除
                                    </a>
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
            <div class="am-u-lg-12 am-cf">

                <div class="am-fr" id="page">
                    {$page|raw}
                </div>
            </div>
        </div>
    </div>
    <!-- 修改密码 -->
    <div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
        <div class="am-modal-dialog">
          <div class="am-modal-hd">文字管理系统</div>
          <div class="am-modal-bd">
            <input type="password" class="am-modal-prompt-input" id="old" name="oldAdmPass" placeholder="请输入旧密码(至少六位数)" style="text-align: center;">
            <input type="password" class="am-modal-prompt-input" id="news" name="admPass" placeholder="请输入新密码(至少六位数)" style="text-align: center;">
          </div>
          <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>提交</span>
          </div>
        </div>
    </div> 
    <button
        id="show"
        type="button"
        class="am-btn am-btn-primary"
        data-am-modal="{target: '#my-alert'}" style="display: none;">
        Alert
    </button>
    <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
        <div class="am-modal-dialog">
          <div class="am-modal-hd" id="mian">文字管理系统</div>
          <div class="am-modal-bd">
           
          </div>
          <div class="am-modal-footer">
            <span class="am-modal-btn" onclick="shua()">确定</span>
          </div>
        </div>
    </div> 
    <div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
        <div class="am-modal-dialog">
          <div class="am-modal-bd">
            你，确定要删除这条评论吗？
          </div>
          <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
          </div>
        </div>
      </div>
    <script>

        function commentDel(e){
            $('#my-confirm').modal({
                relatedTarget: this,
                onConfirm: function(options) {
                    $.ajax({
                        url: "http://cms.com:8081/admin/admin/commentDel",
                        type: "POST",
                        data: {comtID:e},
                        success: function (data) {
                            // console.log(JSON.parse(data))
                            if(data == 1){
                                $('#mian').text('删除成功！')
                                $('#my-alert').modal({})
                            }else{
                                $('#mian').text('删除失败！')
                                $('#my-alert').modal({})
                            } 
                        }
                    });
                    
                },
                onCancel: function() {
                    
                }
            });
        }

        $(function() {
            $('#doc-prompt-toggle').on('click', function() {
                $('#my-prompt').modal({
                relatedTarget: this,
                onConfirm: function(e) {
                    let old = $("#old").val()
                    let news = $("#news").val()
                    if(old.length <6 || news.length <6){
                        alert('至少六位数字！');
                        return
                    }
                    console.log(old)
                    console.log(news)
                    $.ajax({
                        url: "http://cms.com:8081/admin/admin/admUpdatePass",
                        type: "POST",
                        data: {
                            old,
                            news,
                            id:'{$Think.session.name.admID}'
                        },
                        success: function (data) {
                            if(data == 0){
                                $("#show").click()
                                $(".am-modal-bd").text('旧密码错误！')
                            }
                            if(data == 1){
                                $("#show").click()
                                $(".am-modal-bd").text('修改成功！')
                            }
                        }
                    });
                },
                onCancel: function(e) {
                    // alert('不想改了!');
                }
                });
            });
            });
            function shua(){
                window.location.reload()
            }
    </script>
    <!-- </div> -->
    <script src="/static/assets/js/amazeui.min.js"></script>
    <script src="/static/assets/js/amazeui.datatables.min.js"></script>
    <script src="/static/assets/js/dataTables.responsive.min.js"></script>
    <script src="/static/assets/js/app.js"></script>

</body>

</html>